import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:znmm/UI/A_Common/buttons/easy_button/easy_elevated_button.dart';
import 'package:znmm/UI/A_Common/custom_search_field.dart';
import 'package:znmm/UI/A_Common/image/openImg_view.dart';
import 'package:znmm/UI/ChatPages/chat_page.dart';
import 'package:znmm/config/app_asset.dart';
import 'package:znmm/config/app_color.dart';

class HomeBar extends StatelessWidget implements PreferredSizeWidget {
  const HomeBar({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [Colors.red[100]!, Colors.red[50]!], // 渐变的颜色
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
          ),
        ),
        child: AppBar(
          title: Row(
            children: [
              const CircleAvatar(
                backgroundImage: AssetImage(
                    AppAsset.settingbg), // Replace with your image asset
              ),
              const SizedBox(
                width: 10,
              ),
              Text("跨境魔方",
                  style: TextStyle(fontSize: 18, color: AppColor.black)),
            ],
          ),
          backgroundColor: Colors.transparent, // 背景色透明
          actions: [
            IconButton(
              icon: const Icon(
                Icons.group_add,
                color: Colors.black,
              ),
              onPressed: () {
                // 加入外贸交流群逻辑
              },
            ),
            IconButton(
              icon: const Icon(Icons.group_add, color: Colors.black),
              onPressed: () {
                Get.to(const ChatPage());
              },
            ),
          ],
          bottom: PreferredSize(
            preferredSize: const Size.fromHeight(50),
            child: Container(
              height: 50,
              padding:
                  const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
              child: Row(
                children: [
                  Expanded(
                    child: CustomSearchField(
                      hintText: '搜索公司名/人名/职位(英文)',
                      onTextChanged: (value) {
                        print('User entered: $value');
                      },
                    ),
                  ),
                  const SizedBox(width: 8),
                  EasyElevatedButton(
                    isRounded: true,
                    label: '搜索',
                    color: Colors.red[300],
                    onPressed: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(
                            builder: (context) => const OpenImgView()),
                      );
                    },
                  ),
                ],
              ),
            ),
          ),
        ));
  }

  @override
  Size get preferredSize => const Size.fromHeight(100);
}
